clear all
set more off 
cd "$main_dir/data"

********************************************************************************
* all-income DD results shown in table 4

********************************************************************************


** near far dd
local max_dist 600
local iso_dist 250 
local g ng 
		
use near_far_m`max_dist'_i`iso_dist'_`g',clear

di "SPECIFICATION DETAILS"
di "max" "`max_dist'" 
di "iso" "`iso_dist'" 	
di "`g'" 		
gen treated=l250
gen treated_after=treated*(gap>=0)

egen ring_fe=group(building_id l250)

reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 & tx250_min_number>0 & tx256_min_number>0 ///
	[aweight=building_sample_weight] ,absorb(ring_fe building_id_year) vce(cl building_id)
	

*  near-near dd

local max_dist 250 
local g ng

di "SPECIFICATION DETAILS"
di "max" "`max_dist'" 
di "`g'" 	
use near_near_m`max_dist'_i`max_dist'_`g',clear
drop if inlist(msa, "dc", "sf")>0
gen zero=0

gen treated=sample
gen treated_after=treated*(listing_year>=building_built)

reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)

capture drop building_tag
egen building_tag=tag(building_id)
tab treated if building_tag==1 & building_sample==1 & min_number>0 


* ddd
		
use triple_diff_m600_i250_ng,clear

egen ring_fe=group(building_id l250)

reghdfe lrent sample l250 sample#l250 listing_year#l250 after_250_treated i.listing_bedrooms i.listing_bathrooms  ///
	if building_sample==1 & tx250_min_number>0 & tx256_min_number>0  ///
	[aweight=building_sample_weight],absorb(ring_fe building_id_year) vce(cl building_id)

capture drop building_tag
egen building_tag=tag(building_id)
tab treated if building_tag==1 & building_sample==1 & tx250_min_number>0 & tx256_min_number>0
















